package com.starblink.brand.adapter

import android.view.ViewGroup
import androidx.fragment.app.FragmentActivity
import com.starblink.android.basic.adapter.BaseVH
import com.starblink.android.basic.aroute.CommonRoute
import com.starblink.rocketreserver.fragment.ProductF
import com.starblink.store.view.StoreProductCompareDialog

@Deprecated(message = "已废弃 1.15.2")
class BrandCollectionHolder(
    private val mContext:FragmentActivity,
    parent: ViewGroup,
    private val brandName:String?,
    private val onLoadMore:(position: Int)->Unit
    ): BaseVH<ProductF>(BrandCollectionCardView2(parent.context))  {

    private val cardView = itemView as BrandCollectionCardView2

    override fun onBind(model: ProductF, position: Int) {
        cardView.bindModel(mContext, model,position,brandName){
            //比价弹框
            StoreProductCompareDialog(
                mContext,
                it, it.brotherOffers, ifEqualHaveTag=true,
            ).show(mContext.supportFragmentManager, "product_compare")
        }
        itemView.setOnClickListener{
            //跳转商品外链
            CommonRoute.startProductLink(
                mContext,
                model.url,
                model.id?:"", productId = model.productId ?: "", model.standardSpuIds ?: "",
                model.collected == true,
                model.type,
                model.merchantWeb?.id?:"",
                model.merchantWeb?.merchantName ?: "",
                model.merchantWeb?.logo,
                model.merchantWeb?.subOrNot?: false,
                model.affInfo?.link, model.traceId ?: ""
            )
        }
        //预先加载更多
        onLoadMore.invoke(position)
    }

}